package com.lvy.hczn.transmit.controller;

import com.lvy.hczn.front.common.core.controller.BaseController;
import com.lvy.hczn.front.common.core.domain.AjaxResult;
import com.lvy.hczn.front.common.exception.UtilException;
import com.lvy.hczn.mq.rocket.ParamInfo;
import com.lvy.hczn.transmit.domain.dto.cteck.ProcessingTask;
import com.lvy.hczn.transmit.service.TProcessingTaskService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @description: 生产加工任务
 * @projectName: wms-front
 * @package: com.lvy.hczn.transmit.controller
 * @className: ProcessingTaskController
 * @author: yw
 * @date: 2025/7/4 14:35
 */
@RequestMapping("/api/dt/processingTask")
@RestController
@Slf4j
public class ProcessingTaskController extends BaseController {

    @Autowired
    private TProcessingTaskService processingTaskService;

    @ApiOperation(value = "生产加工任务同步", notes = "生产加工任务同步")
    @PostMapping("/data")
    public AjaxResult syncProcessingTaskFromPlatform(HttpServletRequest request, @RequestBody ProcessingTask processingTask) {
        try {
            processingTaskService.syncProcessingTaskFromPlatform(request, processingTask);
            return AjaxResult.success();
        } catch (Exception e) {
            if (e instanceof UtilException) {
                return AjaxResult.error(e.getMessage());
            } else {
                log.error("syncProcessingTaskFromPlatform同步异常：", e);
                return AjaxResult.error("系统异常");
            }
        }
    }
}
